Overview
CMID Manager V2 is an integrated management solution that allows users to manage access control and time & attendance for employees under the biometric security environment. It has a client-server architecture that is composed of a central DA (device agent) Core server and clients that utilize the DA core service. It is originally designed and intended to work with biometric devices manufactured by CMITech Co. Ltd., such as EF-45.
About This Guide
This guide contains the conceptual information, the procedural information, and other related references about CMID Manager DA Core and CMID REST API. It is intended and written for software developers who are in charge of application development and system integration on various platforms.
If you are new to the CMID Manager V2 solution, we recommend that you familiarize yourself with the CMID Manager V2 Admin Guide first that covers the comprehensive use cases and instructions for using the software.
For other REST API endpoint references that are not covered in this guide, refer to the CMID REST API Specification document (provided separately).
|
Conventions
The following symbols are used throughout this guide. Make sure that you fully understand each symbol and follow the instructions accompanied.
Symbol | Meaning | Description |
---|---|---|
CAUTION |
Indicates a situation that demands prompt and careful action, a specific remedy, or emergency attention. |
|
IMPORTANT |
Indicates important information that let users know the possible cause of a potential problem in a specific situation and the solution. |
|
NOTE |
Indicates necessary or useful information that generally does not requires actions. |
About CMID DA Core Service
The DA Core service works as a core system of the CMID Manager V2 and provides basic backend functions for main service, device, and database management. It incorporates three management modules—Device Manager, Database Manager and Network Manager.
- Device Manager
-
The Device Manager acts as the main service framework of the DA Core and provides a set of components necessary for user and device management.
- Network Manager
-
The Network Manager provides the network interface for the clients and devices, transparently handling connections over TCP/IP socket or REST service.
- Database Manager
-
The Database Manager provides database service to clients based on Maria DB management system. It maintains a database connection pool to improve performance and synchronize database upon CRUD operations.
Each module has access to the database depending on its needs and retrieves and manipulates data when the relevant events occur.
There are two types of clients that use the services provided by DA Core:
- CMID Manager client
-
The CMID Manager client is an off-the-shelf program that the CMID Manager V2 software package comes with. It is intended for system administrators and poses a GUI-based application that allows them to connect to the DA core and perform their common tasks in the front-end.
- REST client
-
REST client is a testing tool that helps developers to create and test HTTP requests according to the relevant REST API specification.
Introduction to CMID REST API
The CMID Manager V2 also provides an API (application programming interface) to give developers the ability to create and build their own applications or custom integrations with CMID solution.
RESTful API
Because the CMID API is organized around REST (Representational State Transfer) architectural style, it can be accessed via HTTP protocol at a predefined set of endpoints or URLs. With predictable resource-oriented URLs, the CMID REST API accepts request bodies and returns responses in JSON format, and uses standard HTTP response codes, authentication, and methods like GET, POST, PUT, and DELETE.
The RESTful API is designed to be available from any programming languages. Thus, once you come to grasp the basic concepts of the API, you will be able to apply them to any platform by using your favorite HTTP/REST library for your programming language.
Now that the business logic and internal complexity are taken care of by CMID DA Core Service, you can focus on how to achieve your goals by identifying and consuming the available resources and actions properly.
REST Client
There are several test tools available that do the work of REST Client for calling REST APIs. For example, you can use GUI REST Clients in desktop application or web browser extension such as Postman or command-line tools like cURL.
We also provide a simple REST program along with a sample project written in C# in order to let you have hands-on practice on our API and to give you an aid for understanding how an application using REST API can be implemented.
Getting Prepared
This section gives the information about the system requirements, the installation procedures, and the environment setup procedures before using CMID REST API.
Setup Overview
You need to install the CMID DA Core service modules—DA Core installer and DB installer—that are included in the CMID Manager V2 installation package.
Before installation, make sure that you check the following prerequisites:
-
Prepare a Workstation or a PC where you install the DA core service modules.
-
Make sure that the Workstation or the PC meets the system requirements.
System Requirements
The system requirements for the CMID DA Core service and the sample project are as follows:
Items | Minimum | Recommended | |
---|---|---|---|
DA Core Service |
Operating System |
Windows 7 |
Windows 10 (64bit) |
CPU |
Intel Core i5 series processors or AMD equivalent |
||
RAM |
4GB |
16GB or higher |
|
Disk Drive |
100GB HDD |
256GB SSD or higher |
|
Database |
|
||
Sample Project |
Development Environment |
|
Installing DA Core
You must install the CMID DA Core in the Workstation or the PC that you choose as the server machine. You can install the DA Core modules by running two installers for Database and DA Core in a row.
|
-
Double-click CMV2_DB_Setup_x.x.x.x.exe to run the Database installer.
-
If the User Account Control warning message window appears, click OK or Yes to continue.
-
"x.x.x.x" stands for version identifiers and may vary depending on the software version
-
-
Click Next.
-
Click Install to start the installation.
-
Click Finish to exit the installer.
-
Double-click CMV2_DA_Core_Setup_x.x.x.x.exe to run DA Core installer.
If the DA Core installer version is lower than 2.1.2.2, the REST service does not work. Contact us at [email protected] to get the latest version. -
Click Next > Install > Finish.
|
Setting Up DA Core
When the installation of the DA Core is completed, you should run CMV2 DA Core Controller first in the server machine to configure basic DA Core settings.
-
Open Control Panel in Windows.
-
Select Large icon or Small icon in View by drop-down menu.
-
Click CMV2 DA Core Controller (32-bit) to run the DA Core Controller.
If the User Account Control warning message window appears, click OK or Yes to continue. -
Type the IP address of Device Agent in IP box under DB.
If you are to test REST API calls in the local PC where the DA Core is installed, you can use "127.0.0.1" as the IP address. -
Click Save to save the changes and click Close.
Do not change the values in Database, User name and Password under DB unless you are advised to do so. Incorrect settings can cause problems in connecting the database. - To Start/Stop Service Manually
-
When the installation is completed, the Device Agent Core service should run automatically as a Windows background service. But, in some cases, you need to start or stop the service manually. To start or stop the service manually, click Start or Stop on the Control tab.
Running Sample Demo
You can download the REST sample demo program and project package here.
-
Extract all the data from the .zip file.
-
The sample project files can be found in the RestApiSample folder.
-
The demo REST client program (RestApiSample.exe) is located in the RestApiSample\bin\Release folder.
-
-
Double-click RestApiSample.exe to run the demo program.
Getting Started
This section describes the first steps you need in order to start using our REST API. It aims to guide you to produce the simplest possible output—a successful response from the most basic request—with the API. As a result, you will be able to get an overall sense of how it works and be successful with other extensive API calls.
Authentication
Before you can make requests with the CMID REST API, you need to take a step for authentication and authorization first in order to access the resources that the API provides. The CMID REST API uses the Basic HTTP Authentication method to allow REST clients to authenticate themselves. It requires you to log in using credentials (user id and password). Upon successful authentication, a new session is established between two entities and you are authorized to consume the API.
|
URI Example
http://192.168.0.100:44336/1.0 |
Using Sample Program
This procedure assumes that you use using our REST client demo program (RestApiSample.exe).
-
Type the URL in the Request URL box, user id and password, and click Login.
http://{host ip address}:44336/1.0/auth/login
-
The default admin credential is ID:
admin
, Password:0000
. -
We recommend that you should change the admin password and add admin accounts by installing and using CMID Manager client. For more information, see 2.5. Installing Client and 3.1.3. Updating Administrator Account in the CMID Manager V2 admin guide.
-
-
When the authorization is completed, you are ready to start making requests.
AuthData auth = new AuthData();
auth.user_id = txtID.Text;
auth.password = txtPwd.Text;
try
{
string json = JsonConvert.SerializeObject(auth);
string retStr = _webRequst.Post(txtAuthURL.Text, json);
AuthResultData authResult = JsonConvert.DeserializeObject<AuthResultData>(retStr);
if (authResult.admin && authResult.logged)
{
lblAuthResult.Text = "Success!";
pnlCommand.Enabled = true;
}
else
{
lblAuthResult.Text = "Fail!";
pnlCommand.Enabled = false;
}
}
catch { lblAuthResult.Text = "Fail!"; }
All the code snippets illustrated in this guide come from Mainform.cs in the RestApiSample folder. |
Using Other REST Clients
If you want to use other REST testing tools, refer to the following examples in raw format:
POST /1.0/auth/login HTTP/1.1
HOST: cmid-server
Content-Type:application/json
{
"user_id": "admin",
"password": "0000"
}
HTTP/1.1 200 OK
Content-Type:application/json
{
"user_id": "admin",
"admin": true,
"logged": true
}
Making First Request
The next step is to send a basic request to the server and receive the response from it. Let us suppose, for instance, that you want to retrieve user information stored in CMID DA Core. The following procedure demonstrates how to achieve your goal.
Using Sample Program
The following example request assumes that a user (user id = 1) is registered already in CMID DA Core database using the CMID Manager client. If the user with ID number 1 does not exist, try a different user ID or add a new user (See Adding User in Tutorials for more information).
-
Type the following URL in the Request URL box and select GET in Method.
http://{host ip address}:44336/1.0/users/1
-
Click Send.
- Request Scheme
-
-
Method:
GET
-
Path:
/1.0/users
,/1.0/users/{user_id}
-
Query parameters (optional):
page={page}&per_page={per_page}&user_id={user_id}&user_name={user_name}
(For more information, see Getting Users Request Query Content)
-
URI Examplehttp://192.168.0.100:44336/1.0/users&page=1&per_page=3&user_id=1&user_name=david
-
Evaluate the response.
txtResponse.Text = _webRequst.Get(txtURL.Text);
Using Other REST Clients
For using other REST testing tools, refer to the following examples in raw format:
POST /1.0/users/{user_id} HTTP/1.1
HOST: cmid-server
Content-Type:application/json
POST /1.0/users&page={page}&per_page={per_page}&user_id={user_id}&user_name={user_name} HTTP/1.1
HOST: cmid-server
Content-Type:application/json
Name | Description | Type | Scheme | Note |
---|---|---|---|---|
user_id |
Specifies the search criteria by a user ID |
string |
Query or Path |
|
page |
The start page of the user list to read |
integer |
Query |
Default: |
per_page |
The last page of the user list to read |
integer |
Query |
Default: |
user_name |
Specifies the search criteria by a user name |
string |
Query |
HTTP/1.1 200 OK
Content-Type:application/json
[
{
"user_id": "1",
"user_name": "David",
"user_type": "01",
"user_type_name": "WORKER",
"access_allowed": true,
"company_id": 0,
"company_name": "CMITech",
"depart_id": "",
"depart_name": "",
"date_of_in": "",
"title_id": "",
"title_name": "",
"company_phone": "",
"cell_phone": "",
"email": "",
"pin_no": "",
"individual_id": 3,
"individual_name": "Bio and Card",
"bypass_card": true,
"user_image": ""
}
]
Name | Description | Type | Notes | |
---|---|---|---|---|
Array |
user_id |
The ID of the user |
string |
|
user_name |
The name of the user |
string |
||
user_type |
Which type the user belongs to in number |
string |
||
user_type_name |
Which type the user belongs to in name |
string |
||
access_allowed |
True if the user is allowed to access devices |
boolean |
||
company_id |
The ID number of the user’s company |
integer |
||
company_name |
The name of the user’s company |
boolean |
||
depart_id |
The ID number of the department that the user belongs to |
integer |
||
depart_name |
The department name that the user belongs to |
string |
||
date_of_in |
The employment date of the user |
string |
||
title_id |
The ID number of the user’s title |
string |
||
title_name |
The title name of the user |
string |
||
company_phone |
The phone number of the user’s company |
string |
||
cell_phone |
The mobile phone number of the user |
string |
||
The email address of the user |
string |
|||
pin_no |
The PIN that the user can present as a credential |
string |
||
individual_id |
The ID number of individual authentication type |
integer |
||
individual_name |
The name of individual authentication type |
string |
||
bypass_card |
True if the user can access using card only |
boolean |
||
user_image |
The preview face image of the user |
string |
Encoded in BASE64 |
Tutorials
This section gives step-by-step instructions for others aspects of using the CMID API after making your first request. It covers a few of common topics or use cases that you are likely to encounter during the implementation. Each topic is intended to describe a use case that exposes how various goals of the API can be combined in order to achieve something.
Managing Device
The device management is one of the common tasks that need to be performed in an early stage mostly. It may include registering device, reading device, and updating device.
Adding Device
Registering a new device to CMID DA Core server is the first step for device management. It leads to connect the device to the server. Once you make a connection between them, you will be able to take a control of the device.
If you make requests to the existing CMID DA Core that has been operating all the while and serves the API calls from other clients, you should check whether the device IP address is registered already in the server by sending a "GET device" (see Reading Device later in this section) request before trying to register a new device. |
-
Type the following URL in the Request URL box and select POST in Method.
http://{host ip address}:44336/1.0/devices
-
Type the request body content in the Body field in JSON format and click Send.
Body Example{"device_ip":"192.168.0.100","device_model":"EF-45","device_port":"9980","device_name":"","device_enabled":true,"company_id":0,"door_id":0,"door_type":0}
- Request Scheme
-
-
Method:
POST
-
Path:
/1.0/devices
-
Body: see Adding Device Request Body Content
-
URI Examplehttp://192.168.0.100:44336/1.0/devices
-
Evaluate the response.
txtResponse.Text = _webRequst.Post(txtURL.Text, txtBody.Text);
References for Adding Device
POST /1.0/devices HTTP/1.1
HOST: cmid-server
Content-Type:application/json
{
"device_ip":"192.168.0.254",
"device_model":"EF45",
"device_port":"9980",
"device_name":"",
"device_enabled":true,
"company_id":"0",
"door_id":"0",
"door_type":"0"
}
Name | Description | Type | Required | Notes |
---|---|---|---|---|
device_ip |
The IP address of the device |
string |
Required |
|
device_model |
The device model name |
string |
Required |
For example, |
device_port |
The port number of the device |
string |
Required |
Default is |
device_name |
The device name |
string |
Optional |
|
device_enabled |
True if the device is enabled |
boolean |
Required |
|
company_id |
The ID number of the user’s company |
integer |
Required |
|
door_id |
The ID number of the door |
integer |
Optional |
|
door_type |
The type of the door that the device controls |
integer |
Optional |
Valid values: |
HTTP/1.1 200 OK
Content-Type:application/json
{
"device_ip":"192.168.0.254",
"device_id":19,
"result":true,
"result_code":0
}
Name | Description | Type | Notes |
---|---|---|---|
device_ip |
The IP address of the registered device |
string |
|
device_id |
The ID number of the device |
integer |
|
result |
True if the device registration is successful |
boolean |
|
result_code |
The code number of the result |
string |
Reading Device
Getting the registered device information enables you to examine whether the data is added correctly. Sometimes, it can be a preliminary step prior to device registration to check whether the IP address that you will enlist is already in use.
-
Type the following URL in the Request URL box and select GET in Method.
http://{host ip address}:44336/1.0/devices/{device ip address}
-
Click Send.
- Request Scheme
-
-
Method:
GET
-
Path:
/1.0/devices/{device_ip}
-
URI Examplehttp://192.168.0.100:44336/1.0/devices/192.168.0.254
-
Evaluate the response.
References for Reading Device
POST /1.0/devices/{device_ip} HTTP/1.1
HOST: cmid-server
Content-Type:application/json
HTTP/1.1 200 OK
Content-Type:application/json
{
"device_ip":"192.168.0.254",
"device_model":"EF-45",
"device_port":"9980",
"device_sn":"",
"device_name":"",
"device_enable":true,
"device_connected":false,
"door_name":"",
"door_direction":""
}
Name | Description | Type | Notes |
---|---|---|---|
device_ip |
The IP address of the device |
string |
|
device_model |
The device model name |
string |
|
device_port |
The port number of the device |
integer |
|
device_sn |
The serial number of the device |
string |
|
device_name |
The name of the device |
string |
|
device_enable |
True if the device is enabled |
boolean |
|
device_connected |
True if the device is connected to server |
boolean |
|
door_name |
The name of the door that the device controls |
string |
|
door_direction |
On which side of the door the device is installed |
string |
Updating Device
If you want to add more information or modify the present data, you can use UPDATE method. The instructions and the references are identical to those of Adding Device except the request method and the URI scheme.
URI Example
http://192.168.0.100:44336/1.0/devices/192.168.0.254 |
txtResponse.Text = _webRequst.Put(txtURL.Text, txtBody.Text);
Registering User
This tutorial give the information about user registration as one of the common tasks. Registering user may consist of two or three sub tasks (for example, adding user and granting permission to user) depending on your goals.
Adding User
You can create a user in the CMID DA Core with the user profile including various personal information by making the following request.
-
Type the following URL in the Request URL box and select POST in Method.
http://{host ip address}:44336/1.0/users
-
Type the request body content in the Body field in JSON format and click Send.
Body Example{"user_id":"1234","user_name":"Paul","user_type":"0","access_allowed":true,"company_id":0,"depart_id":"1","company_phone":"","cell_phone":"","date_of_in":"","date_of_expired":"","title_id":"","email":"[email protected]","password":"","pin_no":"","individual_id":0,"bypass_card":false}
- Request Scheme
-
-
Method:
POST
-
Path:
/1.0/users
-
Body: see Adding User Request Body Content
-
URI Examplehttp://192.168.0.100:44336/1.0/users
-
Evaluate the response.
References for Adding User
POST /1.0/users HTTP/1.1
HOST: cmid-server
Content-Type:application/json
{
"user_id":"1234",
"user_name":"Paul",
"user_type":"01",
"access_allowed":true,
"company_id":0,
"depart_id":"1",
"company_phone":"",
"cell_phone":"",
"date_of_in":"",
"date_of_expired":"",
"title_id":"",
"email":"[email protected]",
"password":"",
"pin_no":"",
"individual_id":0,
"bypass_card":false
}
Name | Description | Type | Required | Notes |
---|---|---|---|---|
user_id |
The ID of the user |
string |
Required |
|
user_name |
The name of the user |
string |
Required |
|
user_type |
Which type the user belongs to in number |
string |
Required |
|
access_allowed |
True if the user is allowed to access devices |
boolean |
Required |
|
company_id |
The ID number of the user’s company |
integer |
Required |
|
depart_id |
The ID number of the department that the user belongs to |
string |
Optional |
|
company_phone |
The phone number of the user’s company |
string |
Optional |
|
cell_phone |
The mobile phone number of the user |
string |
Optional |
|
date_of_in |
The employment date of the user |
string |
Optional |
|
date_of_expired |
The date when the user’s permission is expired |
string |
Optional |
|
title_id |
The ID number of the user’s title |
string |
Optional |
|
The email address of the user |
string |
Optional |
||
password |
The password of the user |
string |
Optional |
|
pin_no |
The PIN that the user can present as a credential |
string |
Optional |
|
individual_id |
The ID of individual authentication type |
integer |
Optional |
|
bypass_card |
True if the user can access using card only |
boolean |
Optional |
HTTP/1.1 200 OK
Content-Type:application/json
{
"user_id":"1234",
"result":true
}
Name | Description | Type | Notes |
---|---|---|---|
user_id |
The ID of the registered user |
string |
|
result |
True if the user registration is successful |
boolean |
Creating User Permission
Adding users does not make them to obtain the privilege for accessing devices that are connected to the server. In order to gain access to devices, you have to give the users the right to access for each device by creating permission.
-
Type the following URL in the Request URL box and select POST in Method.
http://{host ip address}:44336/1.0/users/privileges
-
Type the user ID and the IP address of destination devices in the Body field in JSON format and click Send.
Body Example{"user_id":"1234","privileges":[{"device_ip":"192.168.0.200"}]}
You can put the multiple IP addresses in the privileges
JSON array. For example,{"user_id":"1234","privileges":[{"device_ip":"192.168.0.200"},{"device_ip":"192.168.0.201"},{"device_ip":"192.168.0.203"}]}
- Request Scheme
-
-
Method:
POST
-
Path:
/1.0/users/privileges
-
Body: see Creating Permission Request Body Content
-
URI Examplehttp://192.168.0.100:44336/1.0/users/privileges
-
Evaluate the response.
References for Creating Permission
POST /1.0/users/privileges HTTP/1.1
HOST: cmid-server
Content-Type:application/json
{
"user_id":"1234",
"privilege":
[
{
"device_ip":"192.168.0.200"
},
{
"device_ip":"192.168.0.201"
},
{
"device_ip":"192.168.0.202"
}
]
}
Name | Description | Type | Required | Notes | |
---|---|---|---|---|---|
user_id |
The ID of the user |
string |
Required |
||
privileges |
device_ip |
The IP address of the device |
string |
Required |
HTTP/1.1 200 OK
Content-Type:application/json
{
"user_id":"1234",
"result":true,
"result_code":""
}
Name | Description | Type | Notes |
---|---|---|---|
user_id |
The ID of the user |
string |
|
result |
True if the user permission is written successfully |
boolean |
|
result_code |
The code number of the result |
string |
Getting Logs
The event logs contain a variety of useful information that can be consumed in access control and time & attendance management. The time-based information collected from devices let you monitor various access and attendance events and manage the working time of the employees. You can also get the device history such as device restart records or change logs in device settings or parameters. This section covers how to get event logs by making a REST API call.
-
Type the following URL in the Request URL box and select GET in Method.
http://{host ip address}:44336/1.0/logs
-
Click Send.
- Request Scheme
-
-
Method:
GET
-
Path:
/1.0/logs
-
Query parameters (optional):
page={page}&per_page={per_page}&user_id={user_id}&from_date={from_date}&to_date={to_date}&device_id={device_id}&granted={granted_type}
-
URI Examplehttp://192.168.0.100:44336/1.0/logs
-
Evaluate the response.
References for Getting Logs
POST /1.0/logs HTTP/1.1
HOST: cmid-server
Content-Type:application/json
POST /1.0/logs&page={page}&per_page={per_page}&user_id={user_id}&from_date={from_date}&to_date={to_date}&device_id={device_id}&granted={granted_type} HTTP/1.1
HOST: cmid-server
Content-Type:application/json
Name | Description | Type | Scheme | Note |
---|---|---|---|---|
page |
The start page of the logs to read |
integer |
Query |
|
per_page |
The last page of the logs to read |
integer |
Query |
|
user_id |
Specifies the search criteria by a user ID |
string |
Query |
|
from_date |
The start date of the logs to read |
string |
Query |
Format: yyyymmdd |
to_date |
The last date of the logs to read |
string |
Query |
Format: yyyymmdd |
device_id |
The ID number of the device |
integer |
Query |
|
granted |
Specifies the search criteria by an event result type |
string |
Query or Path |
Valid values: |
HTTP/1.1 200 OK
Content-Type:application/json
[
{
"event_index":1201,
"event_date":"2019-07-01",
"event_time":"14:08:04",
"event_result":"Timeout",
"user_id":"",
"user_name":"",
"door_name":"",
"direction":"",
"device_ip":"",
"device_name":"",
"device_sn":"",
"auth_type":"",
"event_img":""
}
]
Name | Description | Type | Notes | |
---|---|---|---|---|
Array |
event_index |
The incremental index number of the log |
integer |
|
event_date |
The date when the event happened |
string |
Format: |
|
event_time |
The time when the event happened |
string |
Format: |
|
event_result |
The result message of the event handling |
string |
||
user_id |
The ID of the user |
string |
||
user_name |
The name of the user |
string |
||
door_name |
The name of the door that the device controls |
string |
||
direction |
On which side of the door the device is installed |
string |
For example, |
|
device_ip |
The IP address of the device |
string |
||
device_name |
The name of the device |
string |
||
device_sn |
The serial number of the device |
string |
||
auth_type |
In what type the authentication is made |
string |
||
user_image |
The preview face image of the user |
string |
Encoded in BASE64 |